package com.itheima.test1;

import javax.swing.text.DateFormatter;
import java.text.DateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class Test {
    public static void main(String[] args) {
        LocalDate now = LocalDate.now();
        String s = "1999-02-01";
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");

        LocalDate birthday = LocalDate.parse(s, formatter);
        int nowYear = now.getYear();
        int birthdayYear = birthday.getYear();
        int age=nowYear-birthdayYear;
        System.out.println("年龄是:"+age);
    }
}
